﻿/*
 * Copyright 2011 Edward L. Stauff.                  Contact: <EdStauff@gmail.com>.
 * 
 * This file, "TextReaderWrapper.cs", is part of the "Stauffware.Common.IO" class 
 * library.  "Stauffware.Common.IO" is free software: you can redistribute it and/or 
 * modify it under the terms of the GNU Lesser Public License as published by the 
 * Free Software Foundation, either version 3 of the License, or (at your option) 
 * any later version.
 * 
 * "Stauffware.Common.IO" is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser Public License for more 
 * details.
 * 
 * You should have received a copy of the GNU Lesser Public License along with 
 * the "Stauffware.Common" sources.  If not, see <http://www.gnu.org/licenses/>.
 */
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Stauffware.Common.IO
{
	/// <summary>
	/// Each method of this class simply calls itself on the TextReader
	/// returned by the abstract _InnerTextReader property.
	/// </summary>
	/// <remarks>
	/// Base your own TextReader wrapper class on this class, and then
	/// override only the methods whose behaviour you need to modify.
	/// </remarks>

	public abstract class TextReaderWrapper : TextReader
	{
		/// <summary>
		/// Override this property to provide the TextReader that gets
		/// called by the methods of this class.
		/// </summary>
		protected abstract TextReader _InnerTextReader { get; }

		/// <summary>
		/// <see cref="System.IO.TextReader.Close"/>
		/// </summary>
		public override void Close ()
		{
			this._InnerTextReader.Close();
		}

		/// <summary>
		/// <see cref="System.IO.TextReader.Peek"/>
		/// </summary>
		public override int Peek ()
		{
			return this._InnerTextReader.Peek();
		}

		/// <summary>
		/// <see cref="System.IO.TextReader.Read()"/>
		/// </summary>
		public override int Read () 
		{ 
			return this._InnerTextReader.Read(); 
		}

		/// <summary>
		/// <see cref="System.IO.TextReader.Read(char[],int,int)"/>
		/// </summary>
		public override int Read (char[] buffer, int index, int count)
		{
			return this._InnerTextReader.Read(buffer, index, count);
		}

		/// <summary>
		/// <see cref="System.IO.TextReader.ReadBlock"/>
		/// </summary>
		public override int ReadBlock (char[] buffer, int index, int count)
		{
			return this._InnerTextReader.ReadBlock(buffer, index, count);
		}

		/// <summary>
		/// <see cref="System.IO.TextReader.ReadLine"/>
		/// </summary>
		public override string ReadLine ()
		{
			return this._InnerTextReader.ReadLine();
		}

		/// <summary>
		/// <see cref="System.IO.TextReader.ReadToEnd"/>
		/// </summary>
		public override string ReadToEnd ()
		{
			return this._InnerTextReader.ReadToEnd();
		}

	}
}
